package admin_router

import (
	"blog_go/middleware"
	"github.com/gin-gonic/gin"
)

type adminRouterGroup struct {
	*gin.RouterGroup
}

func InitAdminRouter(baseGroup *gin.RouterGroup) {
	adminGroup := baseGroup.Group("/admin")
	// 添加上管理员权限
	adminGroup.Use(middleware.JwtAuthAdmin())

	// 实现方式有多种 使用这种方式完成分组
	settingsGroup := adminGroup.Group("/settings")
	// 实例化对象使用对象方法去调用控制器
	adminRouterGroup{settingsGroup}.AdminSettingsRouter()

	imageGroup := adminGroup.Group("/image")
	AdminImageRouter(imageGroup)

	advertGroup := adminGroup.Group("/advert")
	adminRouterGroup{advertGroup}.AdminAdvertRouter()

	menuGroup := adminGroup.Group("/menu")
	adminRouterGroup{menuGroup}.AdminMenuRouter()

	userGroup := adminGroup.Group("/user")
	adminRouterGroup{userGroup}.AdminUserRouter()

	tagGroup := adminGroup.Group("/tag")
	adminRouterGroup{tagGroup}.AdminTagRouter()

	articleGroup := adminGroup.Group("/article")
	adminRouterGroup{articleGroup}.AdminArticleRouter()

	logStashGroup := adminGroup.Group("/log_stash")
	adminRouterGroup{logStashGroup}.adminLogStashRouter()

	dataGroup := adminGroup.Group("/data")
	adminRouterGroup{dataGroup}.AdminDataRouter()
}
